<template>
  <div class="app-container" v-loading="pageLoading">
    <div class="filter-container">
      <el-select class="filter-item" style="width: 200px" v-model="query.description" placeholder="类型" filterable
        @change="research">
        <el-option v-for="(item, index) in statusOptions" :key="index" :value="item.value"
          :label="item.label"></el-option>
      </el-select>
      <el-button class="filter-item" type="success" plain @click="research">查询</el-button>
    </div>
    <z-table :list="list" :tableProps="tableProps" :columns="columns" @editItem="editItem" @deleteItem="deleteItem">
        <template v-slot:content="v">
            <span v-if="v.key == 'DescriptionType'">{{ getLabelByValue(statusOptions,v.row['DescriptionType']) }}</span>
            <span v-else-if="v.key == 'MsgType'" :class ="getLabelByValue(msgOptions,v.row['MsgType'],'color')"  style="font-weight:650">{{ getLabelByValue(msgOptions,v.row['MsgType']) }}</span>
          </template>
    </z-table>
  </div>
</template>

<script>
import commonMixin from "@/views/_common/mixin";
export default {
  name: "wcsJobLog",
  mixins: [commonMixin],
  data: function () {
    return {
      list:[

      ],
      name: "job日志",
      api: this.$api.wcsUrl + "wcs/DeviceDescription/",
      apiList: this.$api.wcsUrl + "wcs/DeviceDescription/GetDescription",
      columns: [
        { title: "日志类型", key: "DescriptionType", width: 280  },
        { title: "内容", key: "Msg" },
        { title: "消息类型", key: "MsgType", width: 200 },
        { title: "时间", key: "CovertTime", width: 250 },
      ],
      tableProps: {
        border: true,
        opsColWith: 140,
        hideOperations: true,
      },
      query: {
        description: 0,
      },
      statusOptions: [
        { label: "全部", value: 0 },
        { label: "堆垛机任务下发", value: 1 },
        { label: "输送线任务下发", value: 2 },
        { label: "输送线任务请求", value: 3 },
        { label: "RGV任务下发", value: 4 },
        { label: "AGV任务下发", value: 5 },
        { label: "任务归档 ", value: 9 },
      ],
      msgOptions:[
        { label: "提示", value: 1,color:'text-success' },
        { label: "警告", value: 2,color:'text-warning' },
        { label: "错误", value: 3 ,color:'text-danger'},

      ],
    };
  },

  created: function () {
    this.getList();
  },
  methods: {
    getList() {
      this.pageLoading = true;
      let url = this.api + "GetDescription";
      this.http
        .get(url, this.formatQuery(this.query))
        .then((r) => {
          this.list = this.formatList(r);
        })
        .finally(() => {
          this.pageLoading = false;
        });
    },
  },
};
</script>
